home *** CD-ROM | disk | FTP | other *** search
- ;
- ; SFskyedit - Star Fighter 3000 sky colours editor
- ; Sky renderer
- ; Copyright (C) 2001 Chris Bazley
- ;
- ; This program is free software; you can redistribute it and/or modify
- ; it under the terms of the GNU General Public Licence as published by
- ; the Free Software Foundation; either version 2 of the Licence, or
- ; (at your option) any later version.
- ;
- ; This program is distributed in the hope that it will be useful,
- ; but WITHOUT ANY WARRANTY; without even the implied warranty of
- ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ; GNU General Public Licence for more details.
- ;
- ; You should have received a copy of the GNU General Public Licence
- ; along with this program; if not, write to the Free Software
- ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- ;
-
- ; Original version by Fednet Software for Star Fighter 3000
- ; 13.07.01 CJB Modified for APCS-32 compliance
- ; 16.10.03 CJB Tweaked stack check to check for -ve rather than signed lower
-
- ; Routine to draw sky at variable height with variable shading
- ; Ver.4 With vertical clipping end (Height based) end-of-table check
- ; + Star start height at file +4
-
- ; C prototype :
- ; void sky_drawsky(int height_scaler,
- ; SF_SkyColours **sky_address,
- ; void *screen_address,
- ; int scrstart_offset);
- ; -----------------------------------------------------------------------
-
- ; a1 = height scaling number
- ; a2 = Address of pointer to sky colourtable to use
- ; a3 = Start of screen address
- ; a4 = offset from start of screen
-
- ; File +0 = Min height of sky
- ; File +4 = Start height of star plot
- ; +8+= Sky data
- ; -----------------------------------------------------------------------
-
- ; Area name C$$code advisable if wanted to link with C output
-
- AREA |C$$code|, CODE, READONLY
-
- EXPORT |sky_drawsky|
- IMPORT |__rt_stkovf_split_small|
-
- |sky_drawsky|
- ; Create stack backtrace structure
- MOV ip, sp ; save current sp, ready to save as old sp
- STMFD sp!, {v1-v5, fp, ip, lr, pc} ; as needed
- SUB fp, ip, #4 ; points to saved pc
-
- CMP sp, sl ; Stack limit checking
- BLMI |__rt_stkovf_split_small|
-
- LDR a2,[a2] ; get pointer to sky colourtable
-
- MOV lr,a1,ASR#7
- ADD lr,lr,lr,ASR#1
- ADD lr,lr,#48 ; calculate height-related cap for colour index
- CMP lr,#255
- MOVGT lr,#255 ; (48 to 255)
-
- LDR v1,[a2],#8
- ADD a1,a1,v1 ; Add initial height offset
-
- MOV v1,#0 ; Current colour lookup
-
- CMP a4,#81920
- BGE sky_clipsky ; Clip for bottom of screen
-
- ADD a4,a3,a4 ; screen (right) store location
- CMP a4,a3
- LDMLEEA fp, {v1-v5, fp, sp, pc} ; Clip for top of screen
-
- sky_dolineagain
- MOV v3,v1, ASR #10
- ;TST a4,#2_100000
- ; SUBEQ v3,v3,#1 ; Don't understand this, and it is counter-productive
-
- CMP v3,lr
- LDRGT v2,[a2,lr,ASL#2] ; cap colour lookup to R14 (height related)
- LDRLE v2,[a2,v3,ASL#2] ; read word to plot
-
- MOV v3,v2 ; duplicate across four words (16 pixels)
- MOV v4,v2
- MOV v5,v2
-
- ; Store line backwards
-
- STMDA a4!,{v2-v5}
- STMDA a4!,{v2-v5}
- STMDA a4!,{v2-v5}
- STMDA a4!,{v2-v5}
- STMDA a4!,{v2-v5}
- STMDA a4!,{v2-v5}
- STMDA a4!,{v2-v5}
- STMDA a4!,{v2-v5}
- STMDA a4!,{v2-v5}
- STMDA a4!,{v2-v5}
- STMDA a4!,{v2-v5}
- STMDA a4!,{v2-v5}
- STMDA a4!,{v2-v5}
- STMDA a4!,{v2-v5}
- STMDA a4!,{v2-v5}
- STMDA a4!,{v2-v5}
- STMDA a4!,{v2-v5}
- STMDA a4!,{v2-v5}
- STMDA a4!,{v2-v5}
- STMDA a4!,{v2-v5}
-
- CMP a4,a3
- LDMLEEA fp, {v1-v5, fp, sp, pc}
-
- ; Line is complete - now shift up colour bands
-
- ADD v1,v1,a1 ; the higher you are, the narrower the colour bands
- SUBS a1,a1,a1,ASR#5 ; the later bands also change slower
-
- MOV v3,v1, ASR #10
- ;TST a4,#2_100000
- ; SUBEQ v3,v3,#1 ; Don't understand this, and it is counter-productive
-
- CMP v3,lr
- LDRGT v2,[a2,lr,ASL#2] ; cap colour lookup to R14 (height related)
- LDRLE v2,[a2,v3,ASL#2] ; read word to plot
- MOV v2,v2,ROR #8 ; prevent stripes in dithering
-
- MOV v3,v2 ; duplicate across four words (16 pixels)
- MOV v4,v2
- MOV v5,v2
-
- ; Store line backwards
-
- STMDA a4!,{v2-v5}
- STMDA a4!,{v2-v5}
- STMDA a4!,{v2-v5}
- STMDA a4!,{v2-v5}
- STMDA a4!,{v2-v5}
- STMDA a4!,{v2-v5}
- STMDA a4!,{v2-v5}
- STMDA a4!,{v2-v5}
- STMDA a4!,{v2-v5}
- STMDA a4!,{v2-v5}
- STMDA a4!,{v2-v5}
- STMDA a4!,{v2-v5}
- STMDA a4!,{v2-v5}
- STMDA a4!,{v2-v5}
- STMDA a4!,{v2-v5}
- STMDA a4!,{v2-v5}
- STMDA a4!,{v2-v5}
- STMDA a4!,{v2-v5}
- STMDA a4!,{v2-v5}
- STMDA a4!,{v2-v5}
-
- ; Line is complete - now shift up colour bands
- ADD v1,v1,a1,ASL#1
- SUBS a1,a1,a1,ASR#4
-
- CMP a4,a3
- BGT sky_dolineagain
-
- LDMEA fp, {v1-v5, fp, sp, pc}
-
- ; -----------------------------------------------------------------------
-
- sky_clipsky ; Clip sky for bottom of screen
- ADD a4,a3,a4
- ADD v2,a3,#81920
-
- sky_clipskyagain
- ADD v1,v1,a1
- SUBS a1,a1,a1,ASR#5
- SUB a4,a4,#320
- CMP a4,v2
- BLT sky_dolineagain
-
- ADD v1,v1,a1,ASL#1
- SUBS a1,a1,a1,ASR#4
- SUB a4,a4,#320
- CMP a4,v2
- BGE sky_clipskyagain
- B sky_dolineagain
-
- END
-